﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterAdmin.master" AutoEventWireup="true" CodeBehind="EditTimeEmp.aspx.cs" Inherits="UdrinkWater_Project.Admin.EditTimeEmp" %>
<%@ Register assembly="DevExpress.Web.v12.2, Version=12.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxFormLayout" tagprefix="dx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <dx:ASPxRoundPanel ID="ASPxRoundPanel1" runat="server" 
        HeaderText="แก้ไขข้อมูลเข้า-ออกงานพนักงาน" Width="100%">
        <HeaderStyle Font-Size="Medium" HorizontalAlign="Left" />
        <PanelCollection>
            <dx:PanelContent runat="server" SupportsDisabledAttribute="True">
                <dx:ASPxPageControl ID="ASPxPageControl1" runat="server" ActiveTabIndex="0" 
                    Width="100%">
                    <TabPages>
                        <dx:TabPage Text="เวลาเข้างานปกติ">
                            <ContentCollection>
                                <dx:ContentControl runat="server" SupportsDisabledAttribute="True">
                                    <dx:ASPxGridView ID="GV_ShowEditTime" runat="server" Width="100%" 
                                                                        AutoGenerateColumns="False" DataSourceID="SqlData_ShowEditTime" 
                                                                        KeyFieldName="ID_Card;CheckIn_Date" 
                                                                        OnHtmlEditFormCreated="GV_ShowEditTime_HtmlEditFormCreated" 
                                                                        OnRowUpdating="GV_ShowEditTime_RowUpdating">
                                                                        <Columns>
                                                                            <dx:GridViewCommandColumn ShowInCustomizationForm="True" VisibleIndex="8" 
                                                                                Caption="เครื่องมือ">
                                                                                <EditButton Visible="True" Text="แก้ไข">
                                                                                </EditButton>
                                                                                <HeaderStyle HorizontalAlign="Center" />
                                                                            </dx:GridViewCommandColumn>
                                                                            <dx:GridViewDataTextColumn FieldName="ID_Card" ReadOnly="True" 
                                                                                ShowInCustomizationForm="True" VisibleIndex="0" Caption="รหัสพนักงาน">
                                                                                <Settings AllowAutoFilter="False" />
                                                                            </dx:GridViewDataTextColumn>
                                                                            <dx:GridViewDataTextColumn FieldName="Prefix" ShowInCustomizationForm="True" 
                                                                                VisibleIndex="1" Caption="คำนำหน้าชื่อ">
                                                                                <Settings AllowAutoFilter="False" />
                                                                            </dx:GridViewDataTextColumn>
                                                                            <dx:GridViewDataTextColumn FieldName="Firstname" ShowInCustomizationForm="True" 
                                                                                VisibleIndex="2" Caption="ชื่อ">
                                                                                <Settings AllowAutoFilter="False" />
                                                                            </dx:GridViewDataTextColumn>
                                                                            <dx:GridViewDataTextColumn FieldName="Lastname" ShowInCustomizationForm="True" 
                                                                                VisibleIndex="3" Caption="นามสกุล">
                                                                                <Settings AllowAutoFilter="False" />
                                                                            </dx:GridViewDataTextColumn>
                                                                            <dx:GridViewDataDateColumn FieldName="CheckIn_Date" 
                                                                                ShowInCustomizationForm="True" VisibleIndex="4" Caption="วันที่" 
                                                                                ReadOnly="True" Width="150px">
                                                                                <PropertiesDateEdit DateOnError="Null" DisplayFormatString="dd MMMM yyyy">
                                                                                    <CalendarProperties EnableYearNavigation="False">
                                                                                    </CalendarProperties>
                                                                                </PropertiesDateEdit>
                                                                            </dx:GridViewDataDateColumn>
                                                                            <dx:GridViewDataTextColumn Caption="หมายเหตุ" FieldName="Status_Time" 
                                                                                ShowInCustomizationForm="True" VisibleIndex="7" Width="100px">
                                                                                <PropertiesTextEdit EnableFocusedStyle="False">
                                                                                </PropertiesTextEdit>
                                                                                <Settings AllowAutoFilter="False" />
                                                                            </dx:GridViewDataTextColumn>
                                                                            <dx:GridViewDataTimeEditColumn Caption="เวลาเข้างาน" FieldName="CheckIn_Time" 
                                                                                ShowInCustomizationForm="True" VisibleIndex="5">
                                                                                <PropertiesTimeEdit DisplayFormatString="">
                                                                                </PropertiesTimeEdit>
                                                                            </dx:GridViewDataTimeEditColumn>
                                                                            <dx:GridViewDataTimeEditColumn Caption="เวลาออกงาน" FieldName="CheckOut_time" 
                                                                                ShowInCustomizationForm="True" VisibleIndex="6">
                                                                                <PropertiesTimeEdit DisplayFormatString="">
                                                                                </PropertiesTimeEdit>
                                                                            </dx:GridViewDataTimeEditColumn>
                                                                        </Columns>
                                                                        <SettingsPager NumericButtonCount="15" PageSize="15">
                                                                        </SettingsPager>
                                                                        <Settings ShowFilterRow="True" />
                                                                        <Templates>
                                                                            <EditForm>
                                                                                <table style="width: 100%">
                                                                                    <tr>
                                                                                        <td align="right" style="width: 338px; color: #000000">
                                                                                            &nbsp;</td>
                                                                                        <td>
                                                                                            <dx:ASPxLabel ID="lb_IDTime" runat="server" Text="ASPxLabel" Visible="False">
                                                                                            </dx:ASPxLabel>
                                                                                            <dx:ASPxLabel ID="lb_Date" runat="server" Text="ASPxLabel" Visible="False">
                                                                                            </dx:ASPxLabel>
                                                                                        </td>
                                                                                    </tr>
                                                                                    <tr>
                                                                                        <td align="right" style="width: 338px; color: #000000">
                                                                                            สถานะ :</td>
                                                                                        <td>
                                                                                            <dx:ASPxComboBox ID="CB_Status" runat="server" AutoPostBack="True" 
                                                                                                onselectedindexchanged="CB_Status_SelectedIndexChanged" 
                                                                                                ValueType="System.Int32">
                                                                                                <Items>
                                                                                                    <dx:ListEditItem Text="เข้างานปกติ" Value="0" />
                                                                                                    <dx:ListEditItem Text="ขาดงาน" Value="1" />
                                                                                                </Items>
                                                                                            </dx:ASPxComboBox>
                                                                                        </td>
                                                                                    </tr>
                                                                                    <tr>
                                                                                        <td align="right" style="width: 338px; color: #000000">
                                                                                            เวลาเข้างาน :</td>
                                                                                        <td>
                                                                                            <dx:ASPxTimeEdit ID="TimeEdit_In" runat="server">
                                                                                            </dx:ASPxTimeEdit>
                                                                                        </td>
                                                                                    </tr>
                                                                                    <tr>
                                                                                        <td align="right" style="width: 338px; color: #000000">
                                                                                            เวลาออกงาน :</td>
                                                                                        <td>
                                                                                            <dx:ASPxTimeEdit ID="TimeEdit_Out" runat="server">
                                                                                            </dx:ASPxTimeEdit>
                                                                                        </td>
                                                                                    </tr>
                                                                                </table>
                                                                                <div style="text-align: right; padding: 2px 2px 2px 2px">
                <dx:ASPxGridViewTemplateReplacement ID="UpdateButton" ReplacementType="EditFormUpdateButton"
                        runat="server">
                    </dx:ASPxGridViewTemplateReplacement>
                    <dx:ASPxGridViewTemplateReplacement ID="CancelButton" ReplacementType="EditFormCancelButton"
                        runat="server">
                    </dx:ASPxGridViewTemplateReplacement>
                    </div>
                                                                            </EditForm>
                                                                        </Templates>
                                                                    </dx:ASPxGridView>
                                                                    <asp:SqlDataSource ID="SqlData_ShowEditTime" runat="server" 
                                                                        ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
                                                                        
                                                                        
                                                                        
                                        SelectCommand="SELECT TB_Employee.ID_Card, TB_Employee.Prefix, TB_Employee.Firstname, TB_Employee.Lastname, TB_EmpCheckIn.CheckIn_Date, TB_EmpCheckIn.CheckIn_Time, TB_EmpCheckOut.CheckOut_time, TB_StatusCheckTime.Status_Time FROM TB_EmpCheckIn INNER JOIN TB_EmpCheckOut ON TB_EmpCheckIn.Emp_Date = TB_EmpCheckOut.Emp_Date INNER JOIN TB_Employee ON TB_Employee.ID_Card = TB_EmpCheckIn.Employee_ID LEFT OUTER JOIN TB_StatusCheckTime ON TB_EmpCheckIn.Status_Check = TB_StatusCheckTime.Status_Time_Int" UpdateCommand="UPDATE TB_EmpCheckIn SET CheckIn_Time = @CheckIn  
WHERE (Employee_ID =@Emp) AND (CheckIn_Date=@Checkdate);">
                                                                        <UpdateParameters>
                                                                            <asp:Parameter Name="CheckIn" />
                                                                            <asp:Parameter Name="Emp" />
                                                                            <asp:Parameter Name="Checkdate" />
                                                                        </UpdateParameters>
                                                                    </asp:SqlDataSource>
                               
                                </dx:ContentControl>
                            </ContentCollection>
                        </dx:TabPage>
                        <dx:TabPage Text="เวลาเข้างานล่วงเวลา">
                            <ContentCollection>
                                <dx:ContentControl runat="server" SupportsDisabledAttribute="True">
                                    <dx:ASPxGridView ID="GV_EditTimeOver" runat="server" 
                                        AutoGenerateColumns="False" DataSourceID="SqlData_ShoweditOver" 
                                        KeyFieldName="ID_Card;CheckIN_Date" 
                                        OnHtmlEditFormCreated="GV_EditTimeOver_HtmlEditFormCreated" 
                                        OnRowUpdating="GV_EditTimeOver_RowUpdating" Width="100%">
                                        <Columns>
                                            <dx:GridViewCommandColumn ShowInCustomizationForm="True" VisibleIndex="7" 
                                                Caption="แก้ไข">
                                                <EditButton Visible="True" Text="แก้ไข">
                                                </EditButton>
                                                <ClearFilterButton Visible="True">
                                                </ClearFilterButton>
                                                <HeaderStyle HorizontalAlign="Center" />
                                            </dx:GridViewCommandColumn>
                                            <dx:GridViewDataTextColumn FieldName="ID_Card" ReadOnly="True" 
                                                ShowInCustomizationForm="True" VisibleIndex="0" Caption="รหัสพนักงาน">
                                                <Settings AllowAutoFilter="False" />
                                            </dx:GridViewDataTextColumn>
                                            <dx:GridViewDataTextColumn FieldName="Prefix" ShowInCustomizationForm="True" 
                                                VisibleIndex="1" Caption="คำนำหน้า">
                                                <Settings AllowAutoFilter="False" />
                                            </dx:GridViewDataTextColumn>
                                            <dx:GridViewDataTextColumn FieldName="Firstname" ShowInCustomizationForm="True" 
                                                VisibleIndex="2" Caption="ชื่อ">
                                                <Settings AllowAutoFilter="False" />
                                            </dx:GridViewDataTextColumn>
                                            <dx:GridViewDataTextColumn FieldName="Lastname" ShowInCustomizationForm="True" 
                                                VisibleIndex="3" Caption="นามสกุล">
                                                <Settings AllowAutoFilter="False" />
                                            </dx:GridViewDataTextColumn>
                                            <dx:GridViewDataDateColumn FieldName="CheckIN_Date" 
                                                ShowInCustomizationForm="True" VisibleIndex="4" Width="150px" 
                                                Caption="วันที่">
                                                <PropertiesDateEdit DisplayFormatString="dd MMMM yyyy">
                                                </PropertiesDateEdit>
                                            </dx:GridViewDataDateColumn>
                                            <dx:GridViewDataTimeEditColumn FieldName="CheckIn_Time" 
                                                ShowInCustomizationForm="True" VisibleIndex="5" Caption="เวลาเข้างาน">
                                                <PropertiesTimeEdit DisplayFormatString="">
                                                </PropertiesTimeEdit>
                                            </dx:GridViewDataTimeEditColumn>
                                            <dx:GridViewDataTimeEditColumn FieldName="CheckOut_Time" 
                                                ShowInCustomizationForm="True" VisibleIndex="6" Caption="เวลาออกงาน">
                                                <PropertiesTimeEdit DisplayFormatString="">
                                                </PropertiesTimeEdit>
                                            </dx:GridViewDataTimeEditColumn>
                                        </Columns>
                                        <SettingsPager NumericButtonCount="15" PageSize="15">
                                        </SettingsPager>
                                        <Settings ShowFilterRow="True" />
                                        <Templates>
                                            <EditForm>
                                                <table style="width: 100%">
                                                    <tr>
                                                        <td align="right" style="width: 430px">
                                                            &nbsp;</td>
                                                        <td>
                                                            <dx:ASPxLabel ID="lb_IDOver" runat="server" Text="ASPxLabel" Visible="False">
                                                            </dx:ASPxLabel>
                                                            <dx:ASPxLabel ID="lb_DateOver" runat="server" Text="ASPxLabel" Visible="False">
                                                            </dx:ASPxLabel>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td align="right" style="width: 430px">
                                                            เวลาเข้างาน :</td>
                                                        <td>
                                                            <dx:ASPxTimeEdit ID="TimeEditOverIn" runat="server">
                                                            </dx:ASPxTimeEdit>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td align="right" style="width: 430px">
                                                            เวลาออกงาน :</td>
                                                        <td>
                                                            <dx:ASPxTimeEdit ID="TimeEditOverOut" runat="server">
                                                            </dx:ASPxTimeEdit>
                                                        </td>
                                                    </tr>
                                                </table>
                                                 <div style="text-align: right; padding: 2px 2px 2px 2px">
                <dx:ASPxGridViewTemplateReplacement ID="UpdateButton" ReplacementType="EditFormUpdateButton"
                        runat="server">
                    </dx:ASPxGridViewTemplateReplacement>
                    <dx:ASPxGridViewTemplateReplacement ID="CancelButton" ReplacementType="EditFormCancelButton"
                        runat="server">
                    </dx:ASPxGridViewTemplateReplacement>
                    </div>
                                            </EditForm>
                                        </Templates>
                                    </dx:ASPxGridView>
                                    <asp:SqlDataSource ID="SqlData_ShoweditOver" runat="server" 
                                        ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
                                        
                                        SelectCommand="SELECT TB_Employee.ID_Card, TB_Employee.Prefix, TB_Employee.Firstname, TB_Employee.Lastname, TB_EmployeeOT_Out.CheckOut_Time, TB_EmployeeOT_IN.CheckIn_Time, TB_EmployeeOT_IN.CheckIN_Date FROM TB_Employee INNER JOIN TB_EmployeeOT_IN ON TB_Employee.ID_Card = TB_EmployeeOT_IN.Employee_ID INNER JOIN TB_EmployeeOT_Out ON TB_EmployeeOT_IN.Emp_Date = TB_EmployeeOT_Out.Emp_Date" UpdateCommand="UPDATE TB_EmpCheckIn SET CheckIn_Time = @CheckIn  
WHERE (Employee_ID =@Emp) AND (CheckIn_Date=@Checkdate);">
                                        <UpdateParameters>
                                            <asp:Parameter Name="CheckIn" />
                                            <asp:Parameter Name="Emp" />
                                            <asp:Parameter Name="Checkdate" />
                                        </UpdateParameters>
                                    </asp:SqlDataSource>
                                </dx:ContentControl>
                            </ContentCollection>
                        </dx:TabPage>
                    </TabPages>
                </dx:ASPxPageControl>
               
            </dx:PanelContent>
        </PanelCollection>
    </dx:ASPxRoundPanel>
</asp:Content>
